class Solution3 {
    public int myAtoi(String s) {
        if(s.length()==0){
            return 0;
        }
        s=s.trim();
        int len=s.length();
        if(len==0){
            return 0;
        }
        int sigh=1;
        int i=0;
        char ch=s.charAt(i);
        if(ch=='+'||ch=='-'){
            if(ch=='-'){
                sigh=-1;
            }
            i++;
        }
        int result=0;
        int tmp=0;
        while(i<len){
            int num=s.charAt(i)-'0';
            if(num>9||num<0){
                break;
            }
            tmp=result;
            result=result*10+num;
            if(result/10!=tmp){
                if(sigh > 0){
                        return Integer.MAX_VALUE;
                    }else {
                        return Integer.MIN_VALUE;
                    }


            }
            i++;
        }
    return result*sigh;
    }

    public static void main(String[] args) {
//        Solution3 solution3=new Solution3();
//        System.out.println(solution3.myAtoi("42"));
        StringBuilder s1= new StringBuilder("1");
    }
}